﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using OgilvyOne.Model;
using OgilvyOne.Utility;
using OgilvyOne.IDAL;
using OgilvyOne.Model.vico.ccc_interface;

namespace OgilvyOne.SqlServerDAL
{
    public class VicoRegInfo : IVicoRegInfo
    {
        private const string ADD_SQL = "INSERT INTO VICO_REG_INFO(USER_NAME,SEX,BIRTHDAYY,BIRTHDAMM,BIRTHDADD,MOBILE,PHONE,EMAIL,IS_PRODUCT_MANUALS,PROVINCE,CITY,POSTCODE,ADDRESS,VICO_MODEL,DEALER_PROVICE,DEALER_CITY,DEALER,ISCAR,CAR_BRAND,CAR_BRAND_MODEL,CAR_BUY_TIME,VICO_BUY_TIME,VICO_BUY_BUDGET,ISINCEPT,ISAGREE,SOUREC,CAMNAME,CHANNEL,OTHER_CHANNEL,INFO_TYPE,ADDTIME,IP,VICO_MODEL_ID) VALUES(@USER_NAME,@SEX,@BIRTHDAYY,@BIRTHDAMM,@BIRTHDADD,@MOBILE,@PHONE,@EMAIL,@IS_PRODUCT_MANUALS,@PROVINCE,@CITY,@POSTCODE,@ADDRESS,@VICO_MODEL,@DEALER_PROVICE,@DEALER_CITY,@DEALER,@ISCAR,@CAR_BRAND,@CAR_BRAND_MODEL,@CAR_BUY_TIME,@VICO_BUY_TIME,@VICO_BUY_BUDGET,@ISINCEPT,@ISAGREE,@SOUREC,@CAMNAME,@CHANNEL,@OTHER_CHANNEL,@INFO_TYPE,getDate(),@IP,@VICO_MODEL_ID);select @@IDENTITY";
        public int Add(VicoRegInfoModel model)
        {
            SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter("@USER_NAME" ,SqlDbType.VarChar,50),
                new SqlParameter("@SEX", SqlDbType.VarChar,10),
                new SqlParameter("@BIRTHDAYY",SqlDbType.Int,4),
                new SqlParameter("@BIRTHDAMM",SqlDbType.Int,4),
                new SqlParameter("@BIRTHDADD", SqlDbType.Int,4),
                new SqlParameter("@MOBILE", SqlDbType.VarChar,20),
                new SqlParameter("@PHONE",SqlDbType.VarChar,30),
                new SqlParameter("@EMAIL", SqlDbType.VarChar,100),
                new SqlParameter("@IS_PRODUCT_MANUALS", SqlDbType.Int,4),
                new SqlParameter("@PROVINCE",SqlDbType.Int,4),
                new SqlParameter("@CITY",SqlDbType.Int,4),
                new SqlParameter("@POSTCODE", SqlDbType.VarChar,10),
                new SqlParameter("@ADDRESS", SqlDbType.VarChar,255),
                new SqlParameter("@VICO_MODEL",SqlDbType.VarChar,50),
                new SqlParameter("@DEALER_PROVICE",SqlDbType.Int,4),
                new SqlParameter("@DEALER_CITY",SqlDbType.Int,4),
                new SqlParameter("@DEALER",SqlDbType.Int,4),
                new SqlParameter("@ISCAR",SqlDbType.Int,4),
                new SqlParameter("@CAR_BRAND",SqlDbType.VarChar,20),
                new SqlParameter("@CAR_BRAND_MODEL",SqlDbType.VarChar,20),
                new SqlParameter("@CAR_BUY_TIME",SqlDbType.VarChar,20),
                new SqlParameter("@VICO_BUY_TIME",SqlDbType.VarChar,20),
                new SqlParameter("@VICO_BUY_BUDGET",SqlDbType.VarChar,20),
                new SqlParameter("@ISINCEPT",SqlDbType.Int,4),
                new SqlParameter("@ISAGREE",SqlDbType.Int,4),
                new SqlParameter("@SOUREC",SqlDbType.VarChar,20),
                new SqlParameter("@CAMNAME",SqlDbType.VarChar,20),
                new SqlParameter("@CHANNEL",SqlDbType.VarChar,500),
                new SqlParameter("@OTHER_CHANNEL", SqlDbType.VarChar,100),
                new SqlParameter("@INFO_TYPE", SqlDbType.Int,4),
                new SqlParameter("@IP", SqlDbType.VarChar,50),
                new SqlParameter("@VICO_MODEL_ID", SqlDbType.Int,4)
            };

            parms[0].Value = model.User_name;
            parms[1].Value = model.Sex.Replace("无","");
            parms[2].Value = model.Birthdayy;
            parms[3].Value = model.Birthdamm;
            parms[4].Value = model.Birthdadd;
            parms[5].Value = model.Mobile;
            parms[6].Value = model.Phone;
            parms[7].Value = model.Email.Replace("无","");
            parms[8].Value = model.Is_product_manuals;
            parms[9].Value = model.Province;
            parms[10].Value = model.City;
            parms[11].Value = model.Postcode;
            parms[12].Value = model.Address;
            parms[13].Value = model.Vico_model;
            parms[14].Value = model.Dealer_provice;
            parms[15].Value = model.Dealer_city;
            parms[16].Value = model.Dealer;
            parms[17].Value = model.Iscar;
            parms[18].Value = model.Car_brand;
            parms[19].Value = model.Car_brand_model;
            parms[20].Value = model.Car_buy_time;
            parms[21].Value = model.Vico_buy_time;
            parms[22].Value = model.Vico_buy_budget;
            parms[23].Value = model.Isincept;
            parms[24].Value = model.Isagree;
            parms[25].Value = model.Sourec;
            parms[26].Value = model.Camname;
            parms[27].Value = model.Channel;
            parms[28].Value = model.Other_channel;
            parms[29].Value = model.Info_type;
            parms[30].Value = model.Ip;
            parms[31].Value = model.Vico_model_id;

            int id = 0;
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONN_STRING_NON_DTC))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        string s = SQLHelper.ExecuteScalar(trans, CommandType.Text, ADD_SQL, parms).ToString();
                        id = int.Parse(s);
                        trans.Commit();
                         
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return id;
        }

        
        public bool Del(string ids)
        {
            bool re = false;
            string delsql = "delete from VICO_REG_INFO where ID in(" + ids + ")";
            int i = SQLHelper.ExecuteSql(delsql, new SqlParameter[] { });
            if (i > 0)
            {
                re = true;
            }
            return re;
        }

        public PageTools Query(VicoRegInfoModel q, int pagenum, int pagesize)
        {
            string orderstr = " order by addtime desc";
            string where = " where 1=1 ";//条件
            if (q != null)
            {
                if (!string.IsNullOrEmpty(q.User_name))
                {
                    where += " and USER_NAME like '%" + q.User_name + "%'";
                }
                if (!string.IsNullOrEmpty(q.Mobile))
                {
                    where += " and MOBILE ='" + q.Mobile + "'";
                }
                if (!string.IsNullOrEmpty(q.Camname))
                {
                    where += " and CAMNAME='" + q.Camname + "'";
                }
                if (!string.IsNullOrEmpty(q.Sourec))
                {
                    if (q.Sourec == "no")
                    {
                        where += " and (SOUREC='' or SOUREC is null)";
                    }
                    else
                    {
                        where += " and SOUREC='" + q.Sourec + "'";
                    }
                }
                if (!string.IsNullOrEmpty(q.Channel))
                {
                    if (q.Channel == "no")
                    {
                        where += " and (CHANNEL='' or CHANNEL is null)";
                    }
                    else
                    {
                        //支持渠道模糊查询 channel=edm*
                        if (q.Channel.IndexOf("*") > 0)
                        {
                            where += " and CHANNEL like '%" + q.Channel.TrimEnd('*') + "%'";
                        }
                        else
                        {
                            where += " and CHANNEL='" + q.Channel + "'";
                        }
                    }

                }
                if (q.Isincept >= 1)
                {
                    where += " and ISINCEPT=" + (q.Isincept == 2 ? 0 : 1);
                }
                if (!string.IsNullOrEmpty(q.Vico_model))
                {
                    where += " and VICO_MODEL='" + q.Vico_model + "'";
                }
                if (q.Province > 0)
                {
                    where += " and PROVINCE=" + q.Province;
                }
                if (q.City > 0)
                {
                    where += " and CITY=" + q.City;
                }
                if (q.Dealer > 0)
                {
                    where += " and DEALER = " + q.Dealer;
                }
                if (!string.IsNullOrEmpty(q.QStartDate))
                {
                    where += " and ADDTIME>='" + q.QStartDate + "'";
                }

                if (!string.IsNullOrEmpty(q.QEndDate))
                {
                    where += " and ADDTIME<='" + q.QEndDate + " 23:59:59'";
                }
                //按arvato返回状态代码查询
                if (!string.IsNullOrEmpty(q.vico_send_ccc_resultCode))
                {
                    where += " and vico_send_ccc_resultCode="+q.vico_send_ccc_resultCode;
                }
                //查询多个车型ID，已逗号分隔，如车型ID为：12,20,131
                if (!string.IsNullOrEmpty(q.StrVicoModel))
                {
                    where += " and VICO_MODEL_ID in (" + q.StrVicoModel+")";
                }
               
              
            }
            string sql = "select * from (select top " + pagesize + " * from (select top " + pagenum * pagesize + " * from vico_reg_info r " + where + " order by r.id desc) as t order by t.id ) as t2 order by t2.id desc";
            DataSet ds = SQLHelper.Query(sql);
            string csql = "select count(*) from VICO_REG_INFO " + where;
            int counts = 0;
            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_NON_DTC, CommandType.Text, csql, new SqlParameter[] { }))
            {
                if (rdr.Read())
                {
                    counts = rdr.GetInt32(0);
                }
            }
            PageTools page = new PageTools(ds, pagenum, pagesize, counts);

            return page;
        }

        public DataSet QueryImp(VicoRegInfoModel q)
        {
            string orderstr = " order by v.addtime desc";
            string where = " where 1=1 ";//条件
            if (q != null)
            {
                if (!string.IsNullOrEmpty(q.User_name))
                {
                    where += " and v.USER_NAME like '%" + q.User_name + "%'";
                }
                if (!string.IsNullOrEmpty(q.Mobile))
                {
                    where += " and v.MOBILE ='" + q.Mobile + "'";
                }
                if (!string.IsNullOrEmpty(q.Camname))
                {
                    where += " and CAMNAME='" + q.Camname + "'";
                }
                if (!string.IsNullOrEmpty(q.Sourec))
                {
                    if (q.Sourec == "no")
                    {
                        where += " and (SOUREC='' or SOUREC is null)";
                    }
                    else
                    {
                        where += " and SOUREC='" + q.Sourec + "'";
                    }
                }
                if (!string.IsNullOrEmpty(q.Channel))
                {
                    if (q.Channel == "no")
                    {
                        where += " and (CHANNEL='' or CHANNEL is null)";
                    }
                    else
                    {
                        //支持渠道模糊查询 channel=edm*
                        if (q.Channel.IndexOf("*") > 0)
                        {
                            where += " and CHANNEL like '%" + q.Channel.TrimEnd('*') + "%'";
                        }
                        else
                        {
                            where += " and CHANNEL='" + q.Channel + "'";
                        }
                    }
                }
                if (q.Isincept >= 1)
                {
                    where += " and v.ISINCEPT=" + (q.Isincept == 2 ? 0 : 1);
                }
                if (!string.IsNullOrEmpty(q.Vico_model))
                {
                    where += " and v.VICO_MODEL='" + q.Vico_model + "'";
                }
                if (q.Province > 0)
                {
                    where += " and v.PROVINCE=" + q.Province;
                }
                if (q.City > 0)
                {
                    where += " and v.CITY=" + q.City;
                }
                if (q.Dealer > 0)
                {
                    where += " and v.DEALER = " + q.Dealer;
                }
                if (!string.IsNullOrEmpty(q.QStartDate))
                {
                    where += " and v.ADDTIME>='" + q.QStartDate + "'";
                }

                if (!string.IsNullOrEmpty(q.QEndDate))
                {
                    where += " and v.ADDTIME<='" + q.QEndDate + " 23:59:59'";
                }
                //按arvato返回状态代码查询
                if (!string.IsNullOrEmpty(q.vico_send_ccc_resultCode))
                {
                    where += " and vico_send_ccc_resultCode=" + q.vico_send_ccc_resultCode;
                }
                //查询多个车型ID，已逗号分隔，如车型ID为：12,20,131
                if (!string.IsNullOrEmpty(q.StrVicoModel))
                {
                    where += " and VICO_MODEL_ID in (" + q.StrVicoModel + ")";
                }
            }
            string sql = "select v.ID,v.VICO_MODEL,v.USER_NAME,v.SEX,v.MOBILE,v.EMAIL,v.ISINCEPT,v.VICO_BUY_TIME,v.VICO_BUY_BUDGET,dp.cnname,dc.cnname,d.DEALER_NAME,v.CAMNAME,v.SOUREC,v.CHANNEL,v.ADDTIME,v.IP,v.OTHER_CHANNEL,v.vico_receive_ccc_time,v.vico_send_ccc_resultCode,v.vico_send_ccc_resultDesc,v.vico_send_ccc_resultDetail from VICO_REG_INFO as v left join CMS_DICTIONARY as dp on v.DEALER_PROVICE=dp.CID left join CMS_DICTIONARY as dc on v.DEALER_CITY=dc.CID left join VICO_DEALER as d on v.DEALER=d.ID " + where + orderstr;
            DataSet ds = SQLHelper.Query(sql);
            return ds;
        }

        public bool IsExists(string email)
        {
            bool re = false;
            string csql = "select id from VICO_REG_INFO where email='" + StringUtil.ReplaceSecStr(email) + "'";
            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_NON_DTC, CommandType.Text, csql, new SqlParameter[] { }))
            {
                if (rdr.Read())
                {
                    re = true;
                }
            }
            return re;
        }
        private const string SELECT_SQL = "SELECT USER_NAME,SEX,BIRTHDAYY,BIRTHDAMM,BIRTHDADD,MOBILE,PHONE,EMAIL,IS_PRODUCT_MANUALS,PROVINCE,CITY,POSTCODE,ADDRESS,VICO_MODEL,DEALER_PROVICE,DEALER_CITY,DEALER,ISCAR,CAR_BRAND,CAR_BRAND_MODEL,CAR_BUY_TIME,VICO_BUY_TIME,VICO_BUY_BUDGET,ISINCEPT,ISAGREE,SOUREC,CAMNAME,CHANNEL,OTHER_CHANNEL,INFO_TYPE,ADDTIME,IP FROM VICO_REG_INFO WHERE ID=@ID";
        public VicoRegInfoModel GetModel(int id)
        {
            VicoRegInfoModel model = null;
            SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter("@ID" ,SqlDbType.Int)
            };
            parms[0].Value = id;

            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_NON_DTC, CommandType.Text, SELECT_SQL, parms))
            {
                if (rdr.Read())
                {
                    model = new VicoRegInfoModel();
                    model.Id = id;
                    if (!rdr.IsDBNull(0)) model.User_name = rdr.GetString(0);
                    if (!rdr.IsDBNull(1)) model.Sex = rdr.GetString(1);
                    if (!rdr.IsDBNull(2)) model.Birthdayy = rdr.GetInt32(2);
                    if (!rdr.IsDBNull(3)) model.Birthdamm = rdr.GetInt32(3);
                    if (!rdr.IsDBNull(4)) model.Birthdadd = rdr.GetInt32(4);
                    if (!rdr.IsDBNull(5)) model.Mobile = rdr.GetString(5);
                    if (!rdr.IsDBNull(6)) model.Phone = rdr.GetString(6);
                    if (!rdr.IsDBNull(7)) model.Email = rdr.GetString(7);
                    if (!rdr.IsDBNull(8)) model.Is_product_manuals = rdr.GetInt32(8);
                    if (!rdr.IsDBNull(9)) model.Province = rdr.GetInt32(9);
                    if (!rdr.IsDBNull(10)) model.City = rdr.GetInt32(10);
                    if (!rdr.IsDBNull(11)) model.Postcode = rdr.GetString(11);
                    if (!rdr.IsDBNull(12)) model.Address = rdr.GetString(12);
                    if (!rdr.IsDBNull(13)) model.Vico_model = rdr.GetString(13);
                    if (!rdr.IsDBNull(14)) model.Dealer_provice = rdr.GetInt32(14);
                    if (!rdr.IsDBNull(15)) model.Dealer_city = rdr.GetInt32(15);
                    if (!rdr.IsDBNull(16)) model.Dealer = rdr.GetInt32(16);
                    if (!rdr.IsDBNull(17)) model.Iscar = rdr.GetInt32(17);
                    if (!rdr.IsDBNull(18)) model.Car_brand = rdr.GetString(18);
                    if (!rdr.IsDBNull(19)) model.Car_brand_model = rdr.GetString(19);
                    if (!rdr.IsDBNull(20)) model.Car_buy_time = rdr.GetString(20);
                    if (!rdr.IsDBNull(21)) model.Vico_buy_time = rdr.GetString(21);
                    if (!rdr.IsDBNull(22)) model.Vico_buy_budget = rdr.GetString(22);
                    if (!rdr.IsDBNull(23)) model.Isincept = rdr.GetInt32(23);
                    if (!rdr.IsDBNull(24)) model.Isagree = rdr.GetInt32(24);
                    if (!rdr.IsDBNull(25)) model.Sourec = rdr.GetString(25);
                    if (!rdr.IsDBNull(26)) model.Camname = rdr.GetString(26);
                    if (!rdr.IsDBNull(27)) model.Channel = rdr.GetString(27);
                    if (!rdr.IsDBNull(28)) model.Other_channel = rdr.GetString(28);
                    if (!rdr.IsDBNull(29)) model.Info_type = rdr.GetInt32(29);
                    if (!rdr.IsDBNull(30)) model.Addtime = rdr.GetDateTime(30);
                    if (!rdr.IsDBNull(31)) model.Ip = rdr.GetString(31);

                }
            }

            return model;
        }

        #region arvato接口调试
        ///// <summary>
        ///// 获取注册表中的最大ID
        ///// </summary>
        ///// <returns></returns>
        //public int GetMaxID()
        //{
        //    int maxId = -1;
        //    string strSql = "select max(id) from VICO_REG_INFO";
        //    DataTable dt = SQLHelper.Query(strSql, SQLHelper.CONN_STRING_NON_DTC).Tables[0];
        //    if (dt != null && dt.Rows.Count > 0)
        //    {
        //        maxId = int.Parse(dt.Rows[0][0].ToString());
        //    }
        //    return maxId;

        //}
        /// <summary>
        /// 获取注册日期
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetAddTime(int id)
        {
            string datetime = string.Empty;
            string strSql = "select addtime from dbo.VICO_REG_INFO where id=" + id;
            DataTable dt = SQLHelper.Query(strSql, SQLHelper.CONN_STRING_NON_DTC).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                datetime = Convert.ToDateTime(dt.Rows[0][0].ToString()).ToString("yyyy-MM-dd HH:mm:ss");

            }
            return datetime;
        }
        /// <summary>
        /// 更新发送avato接口结果状态，包括resultcode，resultdesc,resultdetail
        /// </summary>
        public int UpdateSendResultStatus(int id, string resultCode, string resultDesc, string resultDetail)
        {
            int i = -1;
            string strSql = @"update dbo.VICO_REG_INFO 
                              set vico_send_ccc_resultCode='" + resultCode +
                              "',vico_send_ccc_resultDesc='" + resultDesc +
                              "',vico_send_ccc_resultDetail='" + resultDetail + "'  where id=" + id;

            i = SQLHelper.ExecuteSql(strSql, SQLHelper.CONN_STRING_NON_DTC);
            return i;

        }

        /// <summary>
        /// 更新返回错误状态信息，如avato webservices不可用，或网络原因造成的错误
        /// </summary>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public int UpdateSendError(int id, string errMsg)
        {
            int i = -1;
            string strSql = @"update dbo.VICO_REG_INFO 
                              set vico_send_errorDesc='" + errMsg +
                              "',vico_send_ccc_resultCode='-1'" +
                              "  where id=" + id;

            i = SQLHelper.ExecuteSql(strSql, SQLHelper.CONN_STRING_NON_DTC);
            return i;
        }

        /// <summary>
        /// 更新avato webservice 返回状态信息时间
        /// </summary>
        /// <param name="receiviTime"></param>
        /// <returns></returns>
        public int UpdateReceive_CCC_Time(int id, DateTime receiviTime)
        {
            int i = -1;
            string strSql = @"update dbo.VICO_REG_INFO 
                              set vico_receive_ccc_time='" + receiviTime +
                              "'  where id=" + id;

            i = SQLHelper.ExecuteSql(strSql, SQLHelper.CONN_STRING_NON_DTC);
            return i;
        }

        /// <summary>
        /// 根据数据子来源获取对应的数据来源
        /// </summary>
        /// <param name="strSourceSub"></param>
        /// <returns></returns>
        public string GetSource(string strSourceSub)
        {
            string strSource = string.Empty;
            string strSql = "select cnname from dbo.CMS_DICTIONARY where cid in(select upid from dbo.CMS_DICTIONARY where cnname='" + strSourceSub + "' ) and   upid!=0";
            DataTable dt = SQLHelper.Query(strSql, SQLHelper.CONN_STRING_NON_DTC).Tables[0];
            if(dt!=null && dt.Rows.Count>0)
            {
                strSource = dt.Rows[0][0].ToString();     
            }
            
            return strSource;
            
        }

        /// <summary>
        ///  将推送给arvato的传输中的数据明细记录到VICO_Transfer_Arvato_Detail表中
        /// </summary>
        /// <param name="transferModel"></param>
        /// <returns></returns>
        public int InsertToTransferDetail(record transferRecord)
        {
           
            int i = -1;
            try
            {
                string strSql = @"insert into VICO_Transfer_Arvato_Detail(
RecordID,CustomerName,Title,Birthday,MOBILE,SecondMobile,PHONE,EMAIL,ADDRESS,POSTCODE,PROVINCE,CITY,District,IS_PRODUCT_MANUALS,VicoBrand,
VicoSeries,VICO_MODEL,VicoBuyTime,VicoBuyDetailTime,VicoBuyBudget,VicoBuyDetailBudget,ISINCEPT,SOURCE,SourceSub,ChannelSource,ChannelSourceSub,ISCAR,
CarBuyTime,BRAND,Series,Model,TestModels,FirstDate,TenDate,VipCardNo,DEALERPROVICE,DEALERCITY,DEALERName,IsMobile,IsEmail,CAMNAME,INFO_TYPE,
PUSHTIME,TransferTotal,TransferNumericalTime, ReceiveTime,ResultCode,ResultDesc,ResultDetail,SendErrorDesc,type)
values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',
                          '{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}',
                          '{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}','{39}','{40}','{41}',
                          '{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}')";
                strSql=string.Format(strSql,new string []{
                          transferRecord.recordID.ToString(),
                          transferRecord.customerName.Replace("'", "''"),
                          transferRecord.title, 
                          transferRecord.birthday, 
                          transferRecord.mobile,
                          transferRecord.secondMobile, 
                          transferRecord.phone,
                          transferRecord.email.Replace("'", "''"),
                          transferRecord.address.Replace("'", "''"),
                          transferRecord.postCode,
                          transferRecord.province,
                          transferRecord.city,
                          transferRecord.district,
                          transferRecord.isProductManuals,
                          transferRecord.vicoBrand,
                          transferRecord.vicoSeries,
                          transferRecord.vicoModel,
                          transferRecord.vicoBuyTime,
                          transferRecord.vicoBuyDetailTime,
                          transferRecord.vicoBuyBudget, 
                          transferRecord.vicoBuyDetailBudget,
                          transferRecord.isIncept, 
                          transferRecord.source, 
                          transferRecord.sourceSub, 
                          transferRecord.channelSource,
                          transferRecord.channelSourceSub,
                          transferRecord.isHavaCar,
                          transferRecord.carBuyTime, 
                          transferRecord.brand, 
                          transferRecord.series, 
                          transferRecord.model, 
                          transferRecord.testModels,
                          transferRecord.firstDate,
                          transferRecord.tenDate, 
                          transferRecord.vipCardNo, 
                          transferRecord.dealerProvince, 
                          transferRecord.dealerCity, 
                          transferRecord.dealerName,
                          transferRecord.isMobile,
                          transferRecord.isEmail,
                          transferRecord.camName, 
                          transferRecord.infoType,
                          transferRecord.PushTime.ToString(),
                          transferRecord.transferTotal, 
                          transferRecord.transferNumericalTime,
                          transferRecord.ReceiveTime.ToString(),
                          transferRecord.ResultCode.ToString(),
                          transferRecord.ResultDesc, 
                          transferRecord.ResultDetail, 
                          transferRecord.SendErrorDesc,"0"});

              
                i = SQLHelper.ExecuteSql(strSql);
            }
            catch
            { 
                
            }
            return i;
        
        }
        #endregion

        public int GetMaxID()
        {
            return 1;
        }
           

    }
}
